// pages/aboutdetail/aboutdetail.js
var app = getApp();
var getSign = require('../../utils/getSign/util.js')
var WxParse = require('../../utils/wxParse/wxParse.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    baseUrl: '',
    Begin_Time: '',
    Lawyer_Add:'',
    Lawyer_Banner:'',
    Lawyer_Brief:'',
    Lawyer_Number:'',
    Working_Life:0,
    Lawyer_Major: [],
    name:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    this.setData({
      name: options.name,
      baseUrl: app.baseUrl
    })
    wx.setNavigationBarTitle({
      title: this.data.name+'律师'//页面标题为路由参数
    })
    var that = this
    this.requestPost('013', options.id, that)
  },
  //发送请求
  requestPost: function (apitype, lawyerId, that) {
    var memberInfo = wx.getStorageSync('memberInfo')
    var postArgs = {
      'Api_Type': apitype,
      'LawyerId': lawyerId,
      'Member_Id': memberInfo.MemberId,
      'Member_Token': memberInfo.MemberToken
    }
    //获取
    getSign.request('https://wx-app-api.sjune.cn/yuren/API.ashx', 'POST', postArgs, '').then(
      (res) => {
        console.log(res, '律师详情')
        if (res.Status == 2) {
          wx.clearStorage({
            success: () => {
              wx.switchTab({
                url: '/pages/index/index',
              })
            }
          })
        } else if (res.Status == 0) {
          var major = res.Data.Lawyer_Major.split(",")
          this.setData({
            Begin_Time: res.Data.Begin_Time,
            Lawyer_Add: res.Data.Lawyer_Add,
            Lawyer_Banner: res.Data.Lawyer_Banner,
            Lawyer_Brief: res.Data.Lawyer_Brief,
            Lawyer_Number: res.Data.Lawyer_Number,
            Working_Life: res.Data.Working_Life,
            Lawyer_Major: major
          })

          console.log(this.data.Lawyer_Major)
          var content = res.Data.Lawyer_Brief
          WxParse.wxParse('content', 'html', content, that, 5);
        }
        
  
      },
      (err) => {
        console.log(err.Message, '成功列表失败')
      }
    )
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})